package com.ruoyi.school.handler.wall;

import com.ruoyi.school.enums.AuditTypeEnum;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.Map;

@Component
@RequiredArgsConstructor
public class WallStrategyFactory {
    private final Map<Integer, WallStrategy> strategyMap = new HashMap<>();

    @Autowired
    public WallStrategyFactory(AcademicWallStrategy academicStrategy,
                               PracticeWallStrategy practiceStrategy,
                               SkillCertWallStrategy skillCertStrategy,
                               SoftPatentWallStrategy softPatentWallStrategy) {
        strategyMap.put(AuditTypeEnum.PAC_WALL_TYPE_ACADEMIC.getCode(), academicStrategy);
        strategyMap.put(AuditTypeEnum.PAC_WALL_TYPE_PRACTICE.getCode(), practiceStrategy);
        strategyMap.put(AuditTypeEnum.PAC_WALL_SKILL_CERT.getCode(), skillCertStrategy);
        strategyMap.put(AuditTypeEnum.PAC_WALL_TYPE_PATENT.getCode(), softPatentWallStrategy);
    }

    public WallStrategy getStrategy(Integer auditType) {
        WallStrategy wallStrategy = strategyMap.get(auditType);
//        if (wallStrategy == null) {
//            throw new IllegalArgumentException("无法处理类型: " + auditType);
//        }
        return wallStrategy;
    }
}